package it.cst.entity;


import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TemporalType;
import javax.persistence.Temporal;
import javax.persistence.OneToMany;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.Fetch;
import javax.persistence.JoinColumn;


@Entity
@Table(name="MATCHS")
public class Match {
	@Id
	@Column(name="ID")
	@GeneratedValue
	private Integer id;
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="TIMESTAMP", insertable=false, updatable=false, columnDefinition="timestamp default current_timestamp")
	@org.hibernate.annotations.Generated(value=GenerationTime.INSERT)
	@Temporal(TemporalType.TIMESTAMP)	
	private Date timestamp;
	
	@Column(name="WINTHRESHOLD")
	private Integer winthreshold;
	
	@Column(name="ADDEDBYUSER")
	private Integer addedbyuser;
    
	@OneToMany(fetch=FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(insertable=true,name="idmatch")
	List<Group> groups;
	
	
	public List<Group> getGroups() {
		return groups;
	}

	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}

	public Integer getAddedbyuser() {
		return addedbyuser;
	}

	public void setAddedbyuser(Integer addedbyuser) {
		this.addedbyuser = addedbyuser;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public Integer getWinthreshold() {
		return winthreshold;
	}

	public void setWinthreshold(Integer winthreshold) {
		this.winthreshold = winthreshold;
	}

	public Integer getId() {
		return id;
	}
}
